/*
 *Copyright (c) 2024 Black Sesame Technologies
 *
 *Licensed under the Apache License, Version 2.0 (the "License");
 *you may not use this file except in compliance with the License.
 *You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 *Unless required by applicable law or agreed to in writing, software
 *distributed under the License is distributed on an "AS IS" BASIS,
 *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *See the License for the specific language governing permissions and
 *limitations under the License.
*/

#ifndef CAN_HSCG_CFG_H
#define CAN_HSCG_CFG_H

#ifdef __cplusplus
extern "C"{
#endif

/**
* @page misra_violations MISRA-C:2012 violations
*
* @section [global]
* Violates MISRA 2012 Required Rule 5.1, Identifiers (internal and external) shall not rely 
* on the significance of more than 31 characters. 
* The used compilers use more than 31 chars for identifiers.
*
* @section [global]
* Violates MISRA 2012 Required Rule 5.4, Macro identifiers shall be distinct.
* This violation is due to the AUTOSAR requirement [SWS_BSW_00036] (perform inter module checks).
*
* @section [global]
* Violates MISRA 2012 Required Rule 5.2, Identifiers declared in the same scope and name space shall be distinct.
* This rule does not apply if either identifier is a macro identifier, because this case is covered
* by Rule 5.4 and Rule 5.5.
*
* @section [global]
* Violates MISRA 2012 Required Rule 5.5, Identifiers shall be distinct from macro names.
* The identifier clash is between macro identifiers. Therefore, this rule is incorrectly reported by the tool.
*
* @section Can_HSCG_Cfg_h_REF_1
* Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused macro declarations.
* The usage of this macro is configuration dependent so it cannot be removed.
*/

/*==================================================================================================
*                                        INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
==================================================================================================*/
#include "Can_HSCG_VS_0_PBcfg.h"


/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/


/*==================================================================================================
*                                          CONSTANTS
==================================================================================================*/

/**
* @brief          Implicit index value used by Full can hardware objects.
* @details        Implicit index value used by Full can hardware objects.
*
*/
#define CAN_HSCG_MAX_IDMASK    (Can_IdType)0x1FFFFFFFU

/**
* @brief          Define for the selection of the host interface.
* @details        The selection of the host interface.
*
*/

#define CAN_HSCG_ACTIVE_HIF HSCG_CAN_HIF0

/**
* @brief          Define the default controller used for Platform init and deinit commands.
* @details        Define the default controller used for Platform init and deinit commands.
*
*/

#define HSCG_CAN_CONFIG_DEFAULT_CAN_CTRL_U8 HSCG_CAN_CONFIG_DEFAULT_CAN_CTRL_HOST0_U8

/**
* @brief          Can Controllers. Defines for conversion between object names and object IDs.
* @details        Can Controllers. Defines for conversion between object names and object IDs.
(PR-MCAL-2944)Numeric ID's in configuration and definition of symbolic names in Can_HSCG_Cfg.h file
*
*/

#define CanConf_CanController_CanController_0 ((uint8)0U)
#define CanConf_CanController_CanController_1 ((uint8)1U)

/**
* @brief          Can Hardware Objects.
* @details        Can Hardware Objects.
(PR-MCAL-2944)Numeric ID's in configuration and definition of symbolic names in Can_HSCG_Cfg.h file.
*
*/
#define CanConf_CanHardwareObject_CanHO_Config1_RX0    0U /* RECEIVE object of Can Controller ID = 0 */
#define CanConf_CanHardwareObject_CanHO_Config1_RX1    1U /* RECEIVE object of Can Controller ID = 1 */
#define CanConf_CanHardwareObject_CanHO_Config1_TX0  2U /* TRANSMIT object of Can Controller ID = 0 */
#define CanConf_CanHardwareObject_CanHO_Config1_TX1  3U /* TRANSMIT object of Can Controller ID = 1 */

/*
* @brief          Symbolic names for CanObjectId
* @details        Symbolic names for CanObjectId maintained for compatibility with old testcases/applications 
*
*/
#define CanHO_Config1_RX0  0U /* RECEIVE object of Can Controller ID = 0 */
#define CanHO_Config1_RX1  1U /* RECEIVE object of Can Controller ID = 1 */
#define CanHO_Config1_TX0  2U /* TRANSMIT object of Can Controller ID = 0 */
#define CanHO_Config1_TX1  3U /* TRANSMIT object of Can Controller ID = 1 */

/*
* @brief          Lpdu callout name
* @details        (CAN357_Conf) CanLPduReceiveCalloutFunction - This parameter sets the name of the LPDU callout.
*
*/

#define CAN_HSCG_LPDU_NOTIFICATION_ENABLE  (STD_OFF)

/*
* @brief          Callout function name for timestamp of received frames
*
*/
#define CAN_HSCG_RX_TIMESTAMP  (STD_ON)

/*
* @brief          Callout function name for timestamp of frame confirmations
*
*/
#define CAN_HSCG_ACK_TIMESTAMP  (STD_ON)

/*
* @brief          Callout function name for reporting errors.
*
*/
#define CAN_HSCG_ERROR_NOTIF_ENABLE  (STD_ON)

/*
* @brief          Extended identifiers.
* @details        Extended identifiers.
- (STD_ON)  - if at least one extended identifier is used.
- (STD_OFF) - if no extended identifiers are used at all
If no extended identifiers are used then the IDs and MASKs can be stored in uint16 rather than uint32.
*
*/

#define CAN_HSCG_SET_BAUDRATE_API (STD_ON)
#define CAN_HSCG_USE_DEFAULTCONFIG (STD_OFF)

/*
* @brief          Extended number of can hardware objects
* @details        Extended number of can hardware objects:
- STD_ON if more than 256 can hardware objects are needed (up to 65536)
- STD_OFF if no more than 256 can hardware objects are needed
The specification only allows up to 256 can hardware objects. The driver supports a non-standard extension of this limit.
*
*/
#define CAN_HSCG_MBCOUNTEXTENSION (STD_OFF)

/*
* @brief          Instance # of the driver - used for Det_ReportError().
* @details        Instance # of the driver - used for Det_ReportError().
*
*/
#define CAN_HSCG_INSTANCE 0U

/*
* @brief          The define in order to check the trigger transmit feature is enabled or disabled.
* @details        The define in order to check the trigger transmit feature is enabled or disabled.
*
*/


/*123 Calculate the maximum number of HRH and HTH amd MBs from all config sets */

/*
* @brief          Maximum number of HRHs configured.
*
*/
#define CAN_HSCG_MAXHRH_CONFIGURED 2U

/*
* @brief          Maximum number of HTHs configured.
*
*/       
#define CAN_HSCG_MAXHTH_CONFIGURED 2U

/*
* @brief          The index of the first HTH configured
*
*/  
#define CAN_HSCG_FIRST_HTH_CONFIGURED 2U

/*
* @brief          Maximum number of RXMBs configured.
*
*/  
#define CAN_HSCG_MAXRXMB_CONFIGURED 32U

/*
* @brief          Maximum number of TXMBs configured.
*
*/ 
#define CAN_HSCG_MAXTXMB_CONFIGURED 32U


/*
* @brief          Maximum possible controllers per specific derivative.
* @details        Maximum possible controllers per specific derivative.
*
*/
#define CAN_HSCG_MAXCTRL_SUPPORTED 16U

/**
* @brief          Maximum No. of supported controllers (vary according to Processor Family).
* @details        Maximum No. of supported controllers (vary according to Processor Family).
*
*/
#define CAN_HSCG_MAXCONTROLLERCOUNT 16U

/*
* @brief          Maximum No. of controllers Configured
* @details      Maximum No. of controllers Configured
*
*/
#define CAN_HSCG_MAXCTRL_CONFIGURED 2U

/**
* @brief          Hardware events detected by an interrupt or by polling
* @details        (CAN099) The hardware events may be detected by an interrupt or by polling status flags of the hardware objects.
*                 The configuration possibilities regarding polling is hardware dependent (i.e. which events can be polled, which events need to be polled), and not restricted by this standard.
*                 (CAN007)It shall be possible to configure the driver such that no interrupts at all are used (complete polling).
*
*/

/*
* @brief          This macro enables Can_HSCG_MainFunction_Write() if at least one controller is set to process Tx in Polling Mode.
* @details        This macro enables Can_HSCG_MainFunction_Write() if at least one controller is set to process Tx in Polling Mode.
*
*/
#define CAN_HSCG_TXPOLL_SUPPORTED (STD_ON)

#if (CAN_HSCG_TXPOLL_SUPPORTED == STD_ON)
    #define CAN_HSCG_MAINFUNCTION_MULTIPLE_WRITE (STD_OFF)
#endif

/*
* @brief          This macro enables Can_HSCG_MainFunction_Read() if at least one controller is set to process Rx in Polling Mode.
* @details        This macro enables Can_HSCG_MainFunction_Read() if at least one controller is set to process Rx in Polling Mode.
*
*/
#define CAN_HSCG_RXPOLL_SUPPORTED (STD_ON)

#if (CAN_HSCG_RXPOLL_SUPPORTED == STD_ON)
    #define CAN_HSCG_MAINFUNCTION_MULTIPLE_READ (STD_OFF)  
#endif


/*
* @brief          This macro enables Can_HSCG_MainFunction_ErrorNotification() and is used for reporting errors configured in Polling Mode.
*
*/
#define CAN_HSCG_ERRORNOTIFPOLL_SUPPORTED (STD_ON)

/*
* @brief          Maximum number of MB Filters configured.
* @details        Maximum number of MB Filters configured.
*
*/
#define CAN_HSCG_MAXFILTERCOUNT_0 4U

/**
* @brief          Maximum number of baudrate configured.
* @details        Maximum number of baudrate configured.
*                 Controller Baudrates configured are in kbps
*
*/

#define CAN_HSCG_CFGSET0_BAUDRATE_FC_0_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_0_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_0_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_0_0    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_1_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_1_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_1_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_1_1    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_2_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_2_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_2_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_2_2    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_3_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_3_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_3_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_3_3    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_4_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_4_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_4_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_4_4    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_5_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_5_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_5_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_5_5    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_6_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_6_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_6_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_6_6    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_7_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_7_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_7_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_7_7    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_8_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_8_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_8_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_8_8    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_9_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_9_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_9_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_9_9    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_a_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_a_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_a_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_a_a    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_b_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_b_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_b_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_b_b    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_c_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_c_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_c_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_c_c    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_d_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_d_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_d_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_d_d    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_e_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_e_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_e_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_e_e    1U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_f_0    250U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_f_1    500U
#define CAN_HSCG_CFGSET0_BAUDRATE_FC_f_2    1000U
#define CAN_HSCG_CFGSET0_MAX_BAUDRATE_FC_f_f    1U

/* CAN FD INIT*/
#define CAN_HSCG_FD_MODE_ENABLE (STD_ON)

/*
* @brief          (CAN113_Conf) Specifies the maximum time for blocking function until a timeout is detected. Unit in loops.
* @details        (CAN281) The Can module shall use the free running timer provided by the system service for timeout detection in case the hardware does not react
*                  in the expected time (hardware malfunction) to prevent endless loops.
*
*/

/**
* @brief          Reference to OS counter
*/
#define CAN_HSCG_TIMEOUT_COUNTER_NAME    1000U


/* number of ticks executed in CanTimeoutDuration seconds */
#define CAN_HSCG_TICKS_DELAY_DURATION    (100000U)

/*
* @brief          Precompile Support.
* @details        (CAN220)VARIANT-PRE-COMPILE: Only pre-compile configuration parameters
*
*/

#define CAN_HSCG_PRECOMPILE_SUPPORT (STD_OFF)



/*
* @brief          Periods for cyclic call of Main function
* @details        (ECUC_Can_00484) This parameter describes the period for cyclic call to Can_HSCG_MainFunction_Read or Can_HSCG_MainFunction_Write depending on the referring item. Unit is seconds. 
*                 Different poll-cycles will be configurable if more than one CanMainFunctionPeriod is configured. 
*                 In this case multiple Can_HSCG_MainFunction_Read() or Can_HSCG_MainFunction_Write() will be provided by the CAN Driver module..
*
*/

/*
* @brief          Periods for cyclic call of Main function Mode
* @details        (CAN376_Conf) This parameter describes the period for cyclic call to Can_HSCG_MainFunction_Mode. Unit is seconds.
*
*/
#define CAN_HSCG_MAINFUNCTION_MODE_PERIOD 0U

/*
@brief    Macro used to define the maximum of Can object IDs configured  .
*/
#define CAN_HSCG_MAX_OBJECT_ID ((uint32)4U)

#define CAN_HSCG_MAXHWCTRL_COUNT 16

/*==================================================================================================
*                                      DEFINES AND MACROS
==================================================================================================*/

/*
@brief    Define for the number of controllers configured  .
*/
#define HSCG_CAN_CONTROLLERCOUNT                  2


/*==================================================================================================
*                                             ENUMS
==================================================================================================*/

/*==================================================================================================
*                                STRUCTURES AND OTHER TYPEDEFS
==================================================================================================*/

/*==================================================================================================
*                                GLOBAL VARIABLE DECLARATIONS
==================================================================================================*/

/*==================================================================================================
*                                    FUNCTION PROTOTYPES
==================================================================================================*/


#ifdef __cplusplus
}
#endif

#endif /* CAN_HSCG_CFG_H */

/** @} */
